//*********************************************************
//
//    Copyright (c) Microsoft. All rights reserved.
//    This code is licensed under the Apache License, Version 2.0.
//    THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
//    ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
//    IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
//    PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************

namespace Microsoft.Research.ScientificWorkflow.WorkflowApplicationCommonSL
{
    #region NameSpace
    using System;
    using System.Globalization;
    using System.Runtime.Serialization;
    using System.Text;
    using System.Security.Permissions;
    #endregion

    public class TridentCustomException : Exception
    {
        #region Declaration
        /// <summary>
        /// custom message string
        /// </summary>
        private StringBuilder customMessage;

        /// <summary>
        /// Error caption string
        /// </summary>
        private string errorCaption;

        #endregion

        #region Constructor

        /// <summary>
        /// Constructor - Invokes default base Constructor
        /// </summary>
        public TridentCustomException()
            : base()
        {
        }

        /// <summary>
        /// Constructor - Invokes base Constructor
        /// </summary>
        /// <param name="message">string</param>
        public TridentCustomException(string message)
            : base(message)
        {
        }

        /// <summary>
        /// Constructor - Invokes base Constructor
        /// </summary>
        /// <param name="message">string</param>
        /// <param name="exception">Exception</param>
        public TridentCustomException(string message, Exception innerException)
            : base(message, innerException)
        {
        }

        #endregion

        #region Properties
        /// <summary>
        /// get and set  error caption
        /// </summary>
        public string ErrorCaption
        {
            get
            {
                return this.errorCaption;
            }
            set
            {
                this.errorCaption = string.Empty;
                if (!string.IsNullOrEmpty(value))
                {
                    this.errorCaption = value;
                }
            }
        }

        /// <summary>
        /// get and set Custom Error Message
        /// If errorNumber is non zero value it dispalays Error : Number  
        /// </summary>
        public StringBuilder CustomMessage
        {
            get
            {
                this.customMessage = new StringBuilder();
                
                this.customMessage.Append(this.errorCaption);
                this.customMessage.Append(" ");
                this.customMessage.Append(this.Message);
                return this.customMessage;
            }
        }
        #endregion
    }
}
